package com.wxdc.nmgyt.nmgytwydc.http;

import com.wxdc.nmgyt.nmgytwydc.http.api.RetrofitService;
import com.wxdc.nmgyt.nmgytwydc.model.AccountBean;
import com.wxdc.nmgyt.nmgytwydc.model.BASE_WORKFLOWCURRENT;
import com.wxdc.nmgyt.nmgytwydc.model.COMMIT_AUDIT;
import com.wxdc.nmgyt.nmgytwydc.model.CbYfInfoBean;
import com.wxdc.nmgyt.nmgytwydc.model.CodeBean;
import com.wxdc.nmgyt.nmgytwydc.model.GmYfInfoBean;
import com.wxdc.nmgyt.nmgytwydc.model.JcdInfoBean;
import com.wxdc.nmgyt.nmgytwydc.model.UserLoginBean;
import com.wxdc.nmgyt.nmgytwydc.model.YdInfoBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.AuditResultBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.AuditRolResultBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.UserLoginResultBean;
import com.wxdc.nmgyt.nmgytwydc.model.PicUploadStateBean;
import com.wxdc.nmgyt.nmgytwydc.model.SCommitDataBean;
import com.wxdc.nmgyt.nmgytwydc.model.UserInfoBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.UserRolResultBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.ValidateJcdInfoResultBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.YdAddresultBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.YdEditResultBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.YfEditResultBean;
import com.wxdc.nmgyt.nmgytwydc.model.backresult.YfRemoveReusltBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;

/**
 * Created by Administrator on 2018/4/18.
 * 主要用于Retrofit的初始化：
 */

public class RetrofitHelper {
    private RetrofitService mRetrofitService;

    public RetrofitHelper(RetrofitService retrofitService) {
        mRetrofitService = retrofitService;
    }
    /**
     * 查询用户信息
     * @param name
     * @return
     */
    public Observable<UserInfoBean> getSerachUsers(String name){
        return mRetrofitService.getSerachUsers(name);
    };

    public Observable<List<AccountBean>> login(String name, String pwd){
        return mRetrofitService.postLogin(name,pwd);
    }

    /**
     * 通过token查询该用户下的所有监测点信息
     * @return
     */
    public Observable<List<JcdInfoBean>> getJcdInfo(){
        return mRetrofitService.getJcdInfos();
    }

    /**
     * 多图片上传
     * @param maps
     * @return
     */
    public Observable<List<PicUploadStateBean>> multiUpLoadPics(Map<String, RequestBody> maps){
        return mRetrofitService.multiUpLoadPics(maps);
    }

    /**
     * 单图片上传
     * @param imgFile
     * @return
     */
    public Observable<PicUploadStateBean> singleUpLoadPic(MultipartBody.Part imgFile){
        return mRetrofitService.singleUpLoadPic(imgFile);
    };

    /**
     * 采集表数据提交
     * @param commitDataBeans
     * @param curtUserId
     * @param upUserId
     * @return
     */
    public Observable<ResponseBody> upLoadData(List<SCommitDataBean> commitDataBeans, String curtUserId, String upUserId) {
        return mRetrofitService.uploadData(commitDataBeans, curtUserId, upUserId);
    }

    /**
     * 提交反馈的监测点信息
     * @param bean
     * @return
     */
    public Observable<ResponseBody> commitFeedBackData(JcdInfoBean bean){
        return mRetrofitService.commitFeedBackData(bean);
    }

    /**
     * 获取最新公告内容
     * @return
     */
    public Observable<String> getNoticeContentFun(){
        return mRetrofitService.getNoticeContent();
    }

    /**
     * 用户登录
     * @param loginBean
     * @return
     */
    public Observable<UserLoginResultBean> userLoginService(UserLoginBean loginBean){
        return mRetrofitService.userLogin(loginBean);
    };

    /**
     * 用户角色权限查询
     * @param sid
     * @return
     */
    public Observable<UserRolResultBean> userRolQueryService(String sid){
        return mRetrofitService.userRolQuery(sid);
    }

    /**
     * 获取代码信息表
     * @return
     */
    public Observable<List<CodeBean>> reuqestAllCodeService(){
        return mRetrofitService.requestAllCode();
    }

    /**
     * 样地查询接口
     * @param sampleplotid  样地编号
     * @return
     */
    public Observable<ResponseBody> findYdInfoByPk(String sampleplotid){
        return mRetrofitService.queryYdInfoByFk(sampleplotid);
    }

    /**
     * 新增样地信息
     * @param obj
     * @return
     */
    public Observable<YdAddresultBean> addYdInfo(YdInfoBean obj){
        return mRetrofitService.insertYdInfoTab(obj);
    };

    /**
     * 修改样地信息
     * @param obj
     * @return
     */
    public Observable<YdAddresultBean> editYdInfo(YdInfoBean obj){
        return mRetrofitService.updateYdInfoTab(obj);
    }

    /**
     * 删除样地信息
     * @param sampleploted
     * @return
     */
    public Observable<YdEditResultBean> removeYdInfo(String sampleploted){
        return mRetrofitService.deleteYdInfoTab(sampleploted);
    }
    //-------------------------------草本样方-------------------------------------------------------
    public Observable<List<CbYfInfoBean>> queryCbyfInfo(String id){
        return mRetrofitService.queryCbYfFun(id);
    };

    /**新增草本样方
     * @param obj
     * @return
     */
    public Observable<YfEditResultBean> addCbyfInfo(CbYfInfoBean obj){
        return mRetrofitService.insertCbyfFun(obj);
    }

    /**
     * 修改草本样方
     * @param obj
     * @return
     */
    public Observable<YfEditResultBean> editCbyfInfo(CbYfInfoBean obj){
        return mRetrofitService.updateCbyfFun(obj);
    }

    /**
     * 删除草本样方
     * @param grassid
     * @return
     */
    public Observable<YfRemoveReusltBean> removeCbyfInfo(String grassid){
        return mRetrofitService.deleteCbyfFun(grassid);
    }
    //-------------------------------灌木样方-----------------------------------------
    public Observable<List<GmYfInfoBean>> queryGmyfInfo(String id){
        return mRetrofitService.queryGmyfFun(id);
    }
    public Observable<YfEditResultBean> addGmyfInfo(GmYfInfoBean obj){
        return mRetrofitService.insertGmyfFun(obj);
    }
    public Observable<YfEditResultBean> editGmyfInfo(GmYfInfoBean obj){
        return mRetrofitService.updateGmyfFun(obj);
    }
    public Observable<YfRemoveReusltBean> removeGmyfInfo(String gmid){
        return mRetrofitService.deleteGmyfFun(gmid);
    }
    //-------------------------------审核功能--------------------------------------------------

    /**
     * 获取当前用户的审核权限
     * @return
     */
    public Observable<List<AuditRolResultBean>> getUserAuditRol(){
        return mRetrofitService.getCurtUserAuditRol();
    };

    /**
     * 查询审核数据
     * @param id
     * @return
     */
    public Observable<List<BASE_WORKFLOWCURRENT>> getAuditData(int id) {
        return mRetrofitService.queryAuditData(id);
    }

    /**
     * 提交审核
     * @param commit_audit
     * @return
     */
    public Observable<AuditResultBean> commitAudit(COMMIT_AUDIT commit_audit){
        return mRetrofitService.commitAudit(commit_audit);
    }

    /**
     * 验证该监测点是否已经录入信息
     * @param gempoint
     * @return
     */
    public Observable<ValidateJcdInfoResultBean> validateYdInfo(String gempoint){
        return mRetrofitService.validateJcdExistInfo(gempoint);
    }
}
